package com.sunny.action;

import java.util.List;

import javax.annotation.Resource;


import com.sunny.entity.User;
import com.sunny.service.IUserService;

public class UserAction {
	
	private List<User> users;
	private User user;
	@Resource
	public IUserService userService;
	
	public String listUser(){
		
		System.err.println("============="+userService);
		
		users = userService.listUsers();
		return "list";
	}
	public String addUser(){
		System.err.println("add="+user);
		userService.addUser(user);
		return "success";
	}
	public String updateUser(){
		System.err.println("update="+user);
		userService.updateUser(user);
		return "success";
	}
	
	public String deleteUser(){
		System.err.println("id="+user);
		userService.deleteUserById(user.getId());
		return "success";
	}

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
}
